package com.ogilvy.cms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ogilvy.cms.bean.CmsTemplate;
import com.ogilvy.cms.dao.CmsTemplateDao;
import com.ogilvy.cms.service.CmsTemplateService;
import com.ogilvy.frame.service.BaseServiceImpl;
@Service
public class CmsTemplateServiceImpl extends BaseServiceImpl implements CmsTemplateService{
	@Autowired
	protected CmsTemplateDao CmsTemplateDao;
	public CmsTemplate add(CmsTemplate template) {
		// TODO Auto-generated method stub
		CmsTemplate ct=CmsTemplateDao.save(template);
		return ct;
	}

	public boolean del(int cmtId) {
		// TODO Auto-generated method stub
		CmsTemplateDao.deleteById(cmtId);
		return true;
	}

	public boolean modify(CmsTemplate template) {
		// TODO Auto-generated method stub
		CmsTemplateDao.update(template);
		return true;
	}

	public List<CmsTemplate> query(CmsTemplate template){
		// TODO Auto-generated method stub
		if(isEmpty(template.getCmtName())){
			return  CmsTemplateDao.findAll();
		}
		return CmsTemplateDao.findByProperty("templatename", template.getCmtName());
	}

	public List<CmsTemplate> findById(CmsTemplate template) {
		// TODO Auto-generated method stub
		return CmsTemplateDao.findByProperty("templateid", template.getCmtId());
	}

	public List<CmsTemplate> queryByScreen(Map<String, String> screenMap) {
		// TODO Auto-generated method stub
		
		return CmsTemplateDao.getListByScreen(screenMap);
	}

	public List<CmsTemplate> findByName(Map<String, String> screenMap) {
		// TODO Auto-generated method stub
		return CmsTemplateDao.SelectTempByName(screenMap);
	}
//查询数据库中模板名称
	public boolean checkTemplateName(String cmtName) {
		return CmsTemplateDao.isHaveName(cmtName);
	}


}
